package com.uidp.domain;

import static com.uidp.bundle.Messages.GROUP_NAME_NOT_FOUND;

import java.util.ArrayList;
import java.util.List;

import com.acsior.dac.exeption.DataAccessException;
import com.acsior.sbc.exception.BusinessException;
import com.acsior.sbc.exception.SearchException;
import com.acsior.sbc.exception.ValidationException;
import com.acsior.sbc.impl.hibernate.HibernateBusinessObject;
import com.uidp.hibernatelayer.ModulElementsDAO;
import com.uidp.hibernatelayer.ModulElementsVO;
import com.uidp.search.ModulElementsSearch;

public class ModulElements extends
		HibernateBusinessObject<ModulElementsVO, ModulElementsDAO> {	/**
	 * 
	 * @param username
	 *            - потребителско име
	 * @return IUser - резултат
	 * 
	 * @throws BusinessException
	 * @throws SearchException
	 */
	public static List<ModulElements> searchModulElements(String name)
			throws BusinessException, SearchException {
		ModulElementsSearch search = new ModulElementsSearch(name);
		search.execute();

		if (search.getResult().isEmpty()) {
			throw new BusinessException(GROUP_NAME_NOT_FOUND, name);
		}

		return search.getResult();
	}

	private String elementname;
	private Integer ordering;
	private List<Attributes> attributeses;

	public ModulElements() throws BusinessException {
		super();
	}

	public ModulElements(ModulElementsVO h) throws BusinessException {
		super(h);
	}

	/** @see PersistentObject#initialize() */
	@Override
	protected void initialize() throws BusinessException {
		super.initialize();
		this.attributeses = new ArrayList<Attributes>();
	}

	@Override
	protected void setValues(ModulElementsVO h) throws DataAccessException {
		h.setElementname(getElementname());
		h.setOrdering(getOrdering());

	}

	@Override
	protected void copyProperties(ModulElementsVO d, boolean deepCopy)
			throws BusinessException {
		setElementname(d.getElementname());
		setOrdering(d.getOrdering());

	}

	@Override
	protected void validate() throws ValidationException {
		// TODO Auto-generated method stub

	}

	@Override
	protected Class<ModulElementsDAO> getDAOClass() {
		return ModulElementsDAO.class;
	}

	public String getElementname() {
		return elementname;
	}

	public void setElementname(String elementname) {
		this.elementname = elementname;
	}

	public Integer getOrdering() {
		return ordering;
	}

	public void setOrdering(Integer ordering) {
		this.ordering = ordering;
	}

	public List<Attributes> getAttributeses() {
		return attributeses;
	}

	public void setAttributeses(List<Attributes> attributeses) {
		this.attributeses = attributeses;
	}

}
